FROM golang:1.19.3-alpine3.17 AS builder

#LABEL stage=gobuilder

#ENV CGO_ENABLED 0
ENV GOPROXY https://goproxy.cn,direct
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#
#RUN apk update --no-cache && apk add --no-cache tzdata

WORKDIR /build/

ADD go.mod .
ADD go.sum .
RUN go mod download
COPY . .
RUN go build -ldflags="-s -w" -o /app/metabank-router main.go


FROM alpine
#RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories
#RUN apk update --no-cache && apk add --no-cache tzdata curl

#COPY --from=builder /etc/ssl/certs/ca-certificates.crt /etc/ssl/certs/ca-certificates.crt
#COPY --from=builder /usr/share/zoneinfo/Asia/Shanghai /usr/share/zoneinfo/Asia/Shanghai
#ENV TZ Asia/Shanghai

WORKDIR /app
COPY kubectl /usr/bin/kubectl
COPY --from=builder /app/metabank-router /app/metabank-router
RUN chmod +x /usr/bin/kubectl
EXPOSE 9090

CMD ["./metabank-router"]
